import {
  get,
  post,
  del,
  put
} from './servers/http'

const api = {
  // login
  captchaImage: '/captchaImage', // 登录图片验证码
  login: '/login', // 登录
  loginSingle: 'loginSingle',//单点登录
  loginOut: '/logout', // 退出
  // user
  getInfo: '/getInfo', // 获取用户信息
  getQdqx: '/getQdqx', // 用户权限
  // index
  noticeList: '/system/notice/list', // 获取通知公告列表
  noticeDetails: '/system/notice/', // 公告详情
  prizetypeList: '/prizetype/prizetype/list', // 奖项列表
  prizetypeInfo: '/prizetype/prizetype',
  /**
   * 查看意见  type: 查询类型，1：查询推荐意见 2：查询审核意见 3：查询专家意见
   * type不传时，返回所有环节的意见，并按照流程顺序排序返回。
   */
  ByInstanceId: '/project/base/historyFromData/ByInstanceId/',
  playorderList: '/system/playorder/list', // 首页轮播图

  // 我的申报
  projectList: '/project/base/list', // 申报列表
  comitProject: '/project/base/commit/', // 提交申报
  getExpertappraisal: '/project/base/getExpertappraisal/', // 获取专家评审信息
  tasklist: '/project/base/tasklist',
  urgent: '/project/base/urgent/', // 催办
  tasklist2: '/project/base/tasklist',
  base: '/project/base/',
  rollBackToBeginFlow: '/project/base/rollBackToBeginFlow/', // 撤回
  // 专家评审
  formDataShow: '/project/base/formDataShow/', // 获取渲染表单参数
  formDataSave: '/project/base/formDataSave/', // 专家意见

  // 申报提交保存
  addOrUpdate: '/project/base/addOrUpdate',
  addOrUpdateAndCommit: '/project/base/addOrUpdateAndCommit', // 保存或更新申报信息，同时发起流程
  projectInfo: '/project/base/', // 申报项目信息详细信息
  delProject: '/project/base/', // 删除申报项目信息

  // 申报提交保存1111111111111111111
  addOrUpdate2: '/project/base/addOrUpdate',
  aliyunOssMultipartUpload: "/common/aliyunOssMultipartUpload",
  jflist: '/project/base/list',
  details: '/project/base/',
  cmit: '/project/base/commit/',
  delete1: '/project/base/',
  ossUpload: "/file/ossUpload",
  ossDelete: "/file/ossDelete",
  cmit2: '/project/base/addOrUpdateAndCommit/',
  listType:'/files/type/list',
  listCollectTable:'/collect/table/listCollectTable',
  addcontabel:'/collect/table',
  deletecontabel:'/collect/table',
  // 富文本图片上传
  fileUpload: '/file/upload',
  updateBaseInfo:'/project/base/updateBaseInfo'
}
// 提交
export const cmit = (e) => {
  return get(api.cmit + e)
}

// 查询文件上传类型列表
// export function listType(query) {
//   return request({
//     url: '/files/type/list',
//     method: 'get',
//     params: query
//   })
// }

// 附件列表
export const listCollectTable = (query) => {
  return get(api.listCollectTable,query)
}

// 附件列表
export const listType = (query) => {
  return get(api.listType,query)
}

// 提交
export const cmit2 = (e) => {
  return post(api.cmit2, e)
}

// 删除
export const delete1 = (e) => {
  return del(api.delete1 + e)
}
// 获取详情
export const details = (e) => {
  return get(api.details + e)
}
// 获取通知公告列表
export const jflist = (jflist1) => {
  return get(api.jflist, jflist1)
}

//
export const ossUpload = (data) => {
  return post(api.ossUpload, data)
}
export const addcontabel = (data) => {
  return post(api.addcontabel, data)
}
export const deletecontabel = (data) => {
  return put(api.deletecontabel, data)
}
export const updateBaseInfo = (data) => {
  return post(api.updateBaseInfo, data)
}


//
export const ossDelete = (data) => {
  return post(api.ossDelete + "?id=" + data.id, data)
}

// 获取通知公告列表
export const getaddOrUpdate2 = (params) => {
  return post(api.addOrUpdate2, params)
}

// 获取通知公告列表
export const aliyunOssMultipartUpload = (params) => {
  return post(api.aliyunOssMultipartUpload, params)
}

// 获取通知公告列表
export const getNoticeList = () => {
  return get(api.noticeList)
}

// 验证码操作处理接口
export const captchaImage = () => {
  return get(api.captchaImage)
}

// 登录
export const login = (params) => {
  return post(api.login, params)
}

// 单点登录
export const loginSingle = (params) => {
  return post(api.loginSingle, params)
}

// 获取用户信息
export const getInfo = () => {
  return get(api.getInfo)
}

// 退出登录
export const loginOut = () => {
  return post(api.loginOut)
}

// 获取奖项列表
export const getPrizetypeList = (params) => {
  return get(api.prizetypeList, params)
}

// 我的申报列表
export const getProjectList = (params) => {
  return get(api.projectList, params)
}

// 提交申报
export const comitProject = (id, params) => {
  return get(api.comitProject + id, params)
}

// 提交申报
export const getExpertappraisal = (id, params) => {
  return get(api.getExpertappraisal + id, params)
}

// 获取代办任务
export const tasklist = (params) => {
  return get(api.tasklist, params)
}

// 获取代办任务
export const tasklist2 = (params) => {
  return get(api.tasklist2, params)
}

// 获取代办任务
export const base = (id) => {
  return get(api.base + id)
}

// 奖项详情
export const prizetypeInfo = (params) => {
  return get(api.prizetypeInfo, params)
}

// 专家意见列表
export const formDataShow = (id, params) => {
  return get(api.formDataShow + id, params)
}

// 专家发表意见
export const formDataSave = (id, params) => {
  return post(api.formDataSave + id, params)
}

// 查看意见
export const ByInstanceId = (baseId, type) => {
  return get(`${api.ByInstanceId + baseId}/${type}`)
}

// 催办
export const urgent = (id, params) => {
  return get(api.urgent + id, params)
}

// 首页轮播图
export const playorderList = () => {
  return get(api.playorderList)
}

// 保存或更新申报信息
export const addOrUpdate = (params) => {
  return post(api.addOrUpdate, params)
}

// 公告详情
export const noticeDetails = (id, params) => {
  return get(api.noticeDetails + id, params)
}

// 提交申报信息
export const addOrUpdateAndCommit = (params) => {
  return post(api.addOrUpdateAndCommit, params)
}

// 申报项目信息详细信息.
export const projectInfo = (id, params) => {
  return get(api.projectInfo + id, params)
}

// 用户权限
export const getQdqx = (params) => {
  return get(api.getQdqx, params)
}

//删除申报项目信息
export const delProject = (id, params) => {
  return del(api.delProject + id, params)
}

// 申报撤回
export const rollBackToBeginFlow = (id, params) => {
  return get(api.rollBackToBeginFlow + id, params)
}

// 富文本图片上传
export const fileUpload = (params) => {
  return post(api.fileUpload, params)
}

/**
		 * 富文本使用-根据组件名获取父级
		 * @param vm
		 * @param name
		 * @returns {Vue | null|null|Vue}
		 */
 export function getVmParentByName(vm, name) {
  let parent = vm.$parent
  if (parent && parent.$options) {
    if (parent.$options.name === name) {
    return parent
    } else {
    let res = getVmParentByName(parent, name)
    if (res) {
      return res
    }
    }
  }
  return null
  }
